/**
 * Copyright (c) 2018-2022, NXOS Development Team
 * SPDX-License-Identifier: Apache-2.0
 * 
 * Contains: mailbox
 * 
 * Change Logs:
 * Date           Author            Notes
 * 2023-06-16     JasonHu           Init
 */

#ifndef __IPC_MAILBOX__
#define __IPC_MAILBOX__

#include <nxos_mini.h>
#include <base/fifo.h>
#include <base/clock.h>

typedef struct NX_Mailbox
{
    NX_Fifo *fifo;
} NX_Mailbox;

NX_Mailbox *NX_MailboxCreate(NX_Size size);
NX_Error NX_MailboxDestroy(NX_Mailbox *mbox);
NX_Error NX_MailboxSend(NX_Mailbox *mbox, NX_UArch data);
NX_Error NX_MailboxSendTimeout(NX_Mailbox *mbox, NX_UArch data, NX_TimeVal ms);
#define NX_MailboxTrySend(mbox, data) NX_MailboxSendTimeout(mbox, data, 0)
NX_Error NX_MailboxReceive(NX_Mailbox *mbox, NX_UArch *data);
NX_Error NX_MailboxReceiveTimeout(NX_Mailbox *mbox, NX_UArch *data, NX_TimeVal ms);
#define NX_MailboxTryReceive(mbox, data) NX_MailboxReceiveTimeout(mbox, data, 0)
NX_Error NX_MailboxCheckEmpty(NX_Mailbox *mbox);

#endif /* __IPC_MAILBOX__ */
